#include<key.h>
#include<sys.h>
#include<delay.h>
#include<oled.h>
#include<bluetooth.h>
enum DIR
{
	UP;
	DOWN;
	LEFT;
	RIGHT;
};
struct Snake_tlg
{
	int score;//分数
	int dir;//方向
	int num；
	int size；
	struct{
		int x;
		int y;
	 }coor[62];
}snake;
void DrawRectangle(int x0,int y0,int x1,int y1)
{
	OLED_DrawLine(x0,y0,x0,y1);
	OLED_DrawLine(x0,y1,x1,y1);
	OLED_DrawLine(x1,y1,x1,y0);
	OLED_DrawLine(x1,y0,x0,y0);
}
void Draw1Rectangle(int x0,int y0,int x1,int y1)
{
	int i=0;
    int j=0;
   for(i=x0;i<x1;i++)
       {
        for(j=y0;j<y1;j++)
        {
            OLED_DrawPoint(i,j);
        }
                       
       }
    
}
void DrawInit(int i)
{
	if(i==0)
	{
	//主界面
	DrawRectangle(32,7,96,25);
	DrawRectangle(32,39,96,57);
	OLED_ShowChinese(48,24,,16);
	OLED_ShowChinese(48,56,,16);
	}
	else if(i==1)
	{
	//设置界面
	DrawRectangle(32,7,96,25);
	DrawRectangle(32,39,96,57);
	OLED_ShowString(48,24,,16);
	OLED_ShowString(48,56,,16);//error
	
	}
	else if(i==2)
	{
	//贪吃蛇游戏
	DrawRectangle(0,0,128,7);
	OLED_ShowString(0,6,)
	
	
	
	}
	
	else if(i==3)
	{
	//选择键
	
	
	}
	else 
	{
		OLED_ShowString(64,32,"ERROR" ,24)
	}
}
void GameInit(void)
{
	snake.num=3;
	snake.dir=RIGHT;
	snake.score=0;
	snake.size=10;
	
	
}
int main(void)
{
	//初始化
	OLED_Init();
	KeyInit();
	delay_init();
	DrawInit();
	while(1)
	{
		switch(KeyScan())
		{
			case 1:      break;
			case 2:      break;
			case 3:      break;
			case 4:      break;
			default:break;

		}
		
		
		
		
		
		
		
		
	}
}
int  KeyScan(void)
{
	//k1-k4 分别返回1-4
	if(K1==0)
	{
		delay_ms(10);
		if(K1==0)
		{
			return 1;
		}
		while(!K1);
	}
	
	if(K2==0)
	{
		delay_ms(10);
		if(K2==0)
		{
			return 2;
		}
		while(!K2);
	}
	if(K3==0)
	{
		delay_ms(10);
		if(K3==0)
		{
			return 3;
		}
		while(!K3);
	}
	if(K4==0)
	{
		delay_ms(10);
		if(K4==0)
		{
			return 4;
		}
		while(!K4);
	}
}